$(document).ready(function(){

//回到顶部
$('.top').click(function(){
    $("html, body").animate({scrollTop: 0}, 500);
    return false;
});

//back
$('.back').click(function(){
  window.history.back();
});


var cHeight = 0;

var top = $('.top');

$(window).scroll(function(){

    if ($(this).scrollTop()>cHeight){

        if(!top.hasClass('y') && cHeight>300) top.css("transform","translateY(-100px)").addClass('y');

    } else {

        if(top.hasClass('y') || cHeight<300) top.css("transform","translateY(0px)").removeClass('y');

    }

    cHeight = $(this).scrollTop();

});




})

function bindonload(fname){

    if(window.addEventListener){  
      window.addEventListener("load",fname,false);  
    }  
    else{  
      window.attachEvent("onload",fname);   
    }
}

function initSwiper(id,direction,slidesPerView){

  direction = direction||'horizontal';
  slidesPerView = slidesPerView||1.2;
  var mySwiper = new Swiper ('#'+id+'-swiper', {
        autoplay: 3000,
        slidesPerView :slidesPerView,
        // spaceBetween : 10,
        direction : direction,
        loop:true,
        lazyLoading : true,
        watchSlidesVisibility:true,
        observer:true,
        observeParents:true,
        pagination: {
          el: '.swiper-pagination',
          bulletElement : 'li',
          clickable:true
        },
    } ) ;


}